package com.yanqu.road.server.cmd.activity.langyabang;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.LangYaBangProto;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.langyabang.CrossLangYaBangMgr;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_LANG_YA_BANG_DEAL_PVP_EVENT,desc = "琅琊榜pvp")
public class CrossLangYaBangDealPvpCmd extends CrossUnionCommand {
    private int activityId;
    private int chooseBuildingType;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        LangYaBangProto.DoPvpEventReqMsg msg  = LangYaBangProto.DoPvpEventReqMsg.parseFrom(packet.getBytes());
        activityId = msg.getActivityId();
        chooseBuildingType = msg.getChooseBuildingType();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        LangYaBangProto.DoPvpEventRespMsg.Builder builder = CrossLangYaBangMgr.dealPvp(activityId, packet.getPlayerId(), chooseBuildingType, groupId);
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(GameProtocol.S_LANG_YA_PVP_RESULT_FORM_CROSS,builder);
        MessageHelper.sendPacket(serverId,packet.getPlayerId(),pbMsg);
    }

    @Override
    public void sendData() {

    }
}
